package com.mjsheng.bs.dialogtest;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by BS on 2017/6/2.
 */

public class CustomAdapter extends BaseAdapter {


    private LayoutInflater inflater;
    List<String> items;
    private TextView mTv_item;

    public CustomAdapter(Context context) {

        items = new ArrayList<String>();
        items.add("手机号登录");
        items.add("验证码登录");
        items.add("找回密码");
        items.add("用户注册");

        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int i) {
        return items.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = inflater.inflate(R.layout.item_dialog, null);
            mTv_item = (TextView) view.findViewById(R.id.tv_item);
        }
        mTv_item.setText(items.get(i));
        return view;
    }
}

